def find_the_sum(coins_value, M, N):
    n_sum = 0
    n_sum_list = []
    answer = []
    answer_list = []
    if N < coins_value[0]:
        #return 0
        print(0)
    else:
        for i in range(2*M - 1, -1, -1):
            if coins_value[i] <= N:
                position = i
                break
            
        for j in range(position, -1, -1):    
            for i in range(j, -1, -1):
                n_sum += coins_value[i]
                n_sum_list.append(coins_value[i])
                ##print('j =', j)
                ##print('i =', i)
                ##print('n_sum =', n_sum)
                if n_sum > N:
                    n_sum -= coins_value[i]
                    ##print('n_sum =', n_sum)
                    n_sum_list.pop(-1)
                if n_sum == N:
                ##return n_sum, n_sum_list
                ##print(len(n_sum_list))
                ##print(' '.join([str(i)  for i in n_sum_list]))
                    answer.append(len(n_sum_list))
                    answer_list.append(n_sum_list)
                    break
            n_sum = 0
            n_sum_list = []
            ##print('n_sum =', n_sum)
        for i in range(2*M):
            n_sum += coins_value[i]
        #print('n_sum =', n_sum)
        if answer != []:
            ##minimum = 2*M
            minimum_index = 0
            for i in range(len(answer)):
                if answer[i] < answer[minimum_index]:
                    minimum_index = i
                    ##print('minimum_index =', minimum_index)
            #return answer_list[minimum_index]
            print(answer[minimum_index])
            print(' '.join([str(i)  for i in answer_list[minimum_index]]))
        elif n_sum < N:
            #return -1
            print(-1)
        else:
            #return 0    
            print(0)
                                        

N, M = map(int, input().split())
coins_value_input = list(map(int, input().split()))
coins_value = []
for i in coins_value_input:
    coins_value.append(i)
    coins_value.append(i)
find_the_sum(coins_value, M, N)
